<?php
  header('Content-Type:application/json; charset=UTF-8');
    $username = 'admin';
    $passcode = 'admin';
    session_start();


//判断用户以及密码
if (isset($_POST['username'])){
    if($_POST['username']==$username &&  $_POST['passcode']==$passcode)
    {
        $_SESSION['userflag'] = 1;
        echo '{"status" :1 , "msg" :"登陆成功"}';

    }else{
        echo '{"status" :0 , "msg" :"验证未通过"}';
    }

} else{
    if(isset($_SESSION['userflag'])){
       echo '{"status" :1 , "msg" :"已登陆"}';
    }else{
        echo '{"status" :0 , "msg" :"未登陆"}';
    }
}

?>